/* Copyright 2001,2002,2003 NAH6
 * All Rights Reserved
 *
 * Parts Copyright DoD, Parts Copyright Starium
 *
 */
/*LINTLIBRARY*/

/*#include <math.h>*/
#include "main.h"
#include "celp_sup.h"

/*PROTOLIB1*/
/***************************************************************************

 ROUTINE
               ham

 FUNCTION
               creates hamming window

 SYNOPSIS
               ham(win,n)
   formal

                       data    I/O
       name            type    type    function
       -------------------------------------------------------------------
       win            fxpt_16  i/o     hamming window
       n              int       i      dimension of win

**************************************************************************/
void CreateHam(
fxpt_16 win[],          /* 0.15 format */
int     n)
{
        int     i;
        fxpt_32 acc, incr;

        acc = 0;        /* 0.0 in 0.31 format */
        incr = fxpt_div32(2,(n-1),31);     /* 2.0/(n-1) in 0.31 format */
        for(i = 0; i<n; i++) {
                /*win[i] = 0.54 - 0.46 * cos((2.0 * pi * (i)) / (n-1));*/
                win[i] = fxpt_extract_h( fxpt_sub32(1159641167,
                    fxpt_mult64_fix(987842478, fxpt_cos32(acc),31)) );
//                win[i] = fxpt_sub16(17695,
//                    fxpt_mult16_fast(15073, fxpt_extract_h(fxpt_cos32(acc))));
                acc = fxpt_add32_fast(acc, incr);
        }
}
